﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace ReImage
{
    [Serializable]
    public class UserSettings
    {
        public string ViewFolder { get; set; }
        public string HideFolder { get; set; }
        public string ViewImage { get; set; }
        public string HideImage { get; set; }

        public string RootPath { get; set; }
        public string Destination { get; set; }
        public bool OverWrite { get; set; }
        public bool OverWriteWarning { get; set; }
        public bool OverWriteWarningEverytime { get; set; }

        public int LeftFolderWidth { get; set; }
        public int GapBetweenControl { get; set; }

        public UserSettings()
        {
            RootPath = Environment.CurrentDirectory;
            Destination = string.Empty; // User has not set.. so, it would a copy....
            OverWrite = false;
            OverWriteWarning = true;
            OverWriteWarningEverytime = false;

            ViewFolder = "View &Folder";
            HideFolder = "Hide &Folder";
            ViewImage = "View &Image";
            HideImage = "Hide &Image";
            LeftFolderWidth = 200;
            GapBetweenControl = 20;
        }
        public void Merge(string settingPath)
        {
            // read the path and merge it
        }
        public string CreateDestinationPathIfNotExits()
        {
            string dest = RootPath;
            if (string.IsNullOrEmpty(Destination))
            {
                try
                {
                    DirectoryInfo dr = new DirectoryInfo(RootPath);
                    if (dr.Parent != null)
                    {
                        dest = Path.Combine(dr.Parent.FullName, "copy");
                        if (!Directory.Exists(dest))
                        {
                            Directory.CreateDirectory(dest);
                            // if the directory exist, then only update destination
                            Destination = dest;
                        }
                    }
                }
                catch (Exception Ecsx)
                {
                    Trace.WriteLine("Cant create the copy directory there..." + Ecsx.Message);
                }
            }
            return dest;
        }
    }
}
